<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_DB_active_record extends CI_DB_active_record{
    public function field_data($table = ''){
        $fieldPart1 = parent::field_data($table);
        $fieldPart2 = $this->query("SHOW COLUMNS FROM {$table}")->result();
        $fieldFull = array();
        foreach($fieldPart1 as $f1){
            $fieldFull[$f1->name]['type'] = strtoupper($f1->type);
            $fieldFull[$f1->name]['default'] = $f1->default;
            $fieldFull[$f1->name]['constraint'] = $f1->max_length;
        }
        foreach($fieldPart2 as $f2){
            $fieldFull[$f2->Field]['null'] = ($f2->Null == 'NO')?FALSE:TRUE;
            $fieldFull[$f2->Field]['unsigned'] = (preg_match('/\sunsigned$/',$f2->Type)==TRUE)?TRUE:FALSE;
            $fieldFull[$f2->Field]['auto_increment'] = ($f2->Extra == 'auto_increment')?TRUE:FALSE;
        }
        return $fieldFull;
    }
}